import { RegisterPage } from "../root";
import { schema as IndexSchema } from "./list";
import { schema as editSchema } from "./edit";
import { schema as viewSchema } from "./view";
import { schema as createSchema } from "./create";

import { schema as checkInSchema } from "./checkin";
import { schema as hireSchema } from "./hire";
import { schema as workSchema } from "./work";
import { schema as VerifySchema } from "./verify";
import { schema as MyPendingSchema } from "./my/pending";
import { schema as MyProcessingSchema } from "./my/processing";
import { schema as MyOutdatedSchema } from "./my/outdated";
import { schema as MyDraftSchema } from "./my/draft";
import { schema as workTotalSchema } from "./workTotal";
import * as React from 'react';
import BuySafe from './buy-safe';

import {OrgSelector} from '../team/index';

RegisterPage({
  path: "project",
  label: "项目管理",
  icon: "fa fa-tasks",
  acl: 'project:auth',
  NavComponent: OrgSelector,
  NavComponentTest: ({user, location}) => user.type == 4 && !/\/project\/buy\-safe\/\d+/.test(location.pathname),
  children: [
    {
      path: "list",
      label: "项目列表",
      schema: IndexSchema,
      acl: 'project:list',
      url: "/project/list?org_id=${org_id}"
    },

    {
      path: "verify",
      label: "项目审核",
      schema: VerifySchema,
      acl: 'project:verify',
      url: "/project/verify?org_id=${org_id}"
    },

    {
      path: "my",
      acl: 'project:my',
      label: "我的项目",
      children: [
        {
          path: "processing",
          schema: MyProcessingSchema,
          label: "进行中项目",
          url: "/project/my/processing?org_id=${org_id}"
        },

        {
          path: "pending",
          schema: MyPendingSchema,
          acl: 'project:pending',
          label: "待审核项目",
          url: "/project/my/pending?org_id=${org_id}"
        },

        {
          path: "draft",
          schema: MyDraftSchema,
          label: "待提交项目",
          url: "/project/my/draft?org_id=${org_id}"
        },

        {
          path: "outdated",
          schema: MyOutdatedSchema,
          label: "已结项项目",
          url: "/project/my/outdated?org_id=${org_id}"
        }
      ]
    },
    {
      path: "/project/buy-safe/:id",
      label: "购买保险",
      acl: 'project:create',
      component: BuySafe,
    },
    {
      path: "/project/work",
      label: "时长审批",
      schema: workTotalSchema,
      acl: 'project:verify_reward_time',
      url: "/project/work?org_id=${org_id}"
    },
    {
      path: "/project/create",
      label: "创建项目",
      schema: createSchema,
      acl: 'project:create',
      url: "/project/create?org_id=${org_id}"
    },
    {
      path: "/project/edit/:id",
      label: "修改项目",
      acl: 'project:create',
      schema: editSchema
    },
    {
      path: "/project/view/:id",
      label: "查看项目",
      schema: viewSchema
    },

    {
      path: "/project/checkin/:id",
      label: "签到码管理",
        acl: 'project:create',
        schema: checkInSchema
    },

    {
      path: "/project/hire/:id",
      label: "录用管理",
        acl: 'project:create',
        schema: hireSchema
    },

    {
      path: "/project/work/:id",
      label: "志愿时长",
        acl: 'project:create',
        schema: workSchema
    }
  ]
});
